const { Model, DataTypes } = require('sequelize');

const sequelize = require('./database');

const TeamStaff = require('./staff');
const Project = require('./project');
const User = require('./user');
const Team = require('./team');

class TeamProject extends Model {}

StaffProject.init({

  memo: {
    type: DataTypes.STRING,
    allowNull: true,
    comment:"套路备注"
  },
  teamId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment:"报名参加的比赛项目ID",
    references: {
      model: Team, // 指定关联的模型
      key: 'id'
    }
  },
  projectId: { 
    type: DataTypes.INTEGER, 
    allowNull: false,
    comment:"报名参加的比赛项目ID",
    references: {
      model: Project, // 指定关联的模型
      key: 'id'
    }
  },
  userId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment:"关联用户ID",
    references: {
      model: User, // 指定关联的模型
      key: 'id'
    }
  }

}, {
  sequelize,
  modelName: 'teamproject'
});
StaffProject.belongsTo(Team,{ foreignKey: 'teamId' }) 
StaffProject.belongsTo(Project,{ foreignKey: 'projectId' })
StaffProject.belongsTo(User,{ foreignKey: 'userId' })


module.exports = TeamProject;